﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.Xml.Linq;

namespace TfsStatusPage
{
    public class ProjectInfo
    {
        public String ProjectName { get; set; }
        public Int32 ActiveBugs { get; set; }

        public ProjectInfo(String projectName, Int32 activeBugs)
        {
            ProjectName = projectName;
            ActiveBugs = activeBugs;
        }

        public static ObservableCollection<ProjectInfo> GetProjectInfo(String xmlData)
        {
            XElement projects = XElement.Parse(xmlData);
            ObservableCollection<ProjectInfo> infoList = new ObservableCollection<ProjectInfo>();

            foreach (XElement proj in projects.Nodes())
            {
                infoList.Add(new ProjectInfo((String)proj.Element("Name"),
                                       (Int32)proj.Element("ActiveBugs")));
            }

            return infoList;
        }
    }
}
